#ifndef SHOGICOMMANDMAP_H_INCLUDED
#define SHOGICOMMANDMAP_H_INCLUDED

#include <QString>
#include "shogidef.h"

typedef unsigned int CommandCode;

enum COMMAND_DIRECTION
{
	TO_CLIENT = 0,
	TO_SERVER,
	TO_BOTH
};

typedef unsigned int CommandDirection;

typedef struct CommandMapping
{
	GameState gameState;
	QString cmdString;
	CommandCode cmdCode;
	CommandDirection  cmdDirection;

};


// NOTE: This file is used both in client and server and will need to be maintained to include 
// changes in BOTH client and server!
// NOTE: The enumerations and commandmaps are ORDER DEPENDENT - use caution when updating


enum COMMAND_CODES
{
	NO_COMMAND_FOUND			= 0,		// If no command can be found or some other error occurred
	REJECT,	
	CLIENT_VERSION,							// Commands start at 100 to seperate from non-command
	SERVER_VERSION,
	USERNAME,
	PASSWORD,
	GAME_PARAM_WAIT,
	GAME_PARAM_START,
	GAME_PARAM,
	COMMANDCODES_COUNT
};

static const CommandMapping g_CommandMappings[COMMANDCODES_COUNT] =
{
	{ ALL_STATES,		"NO_COMMAND_FOUND"	,NO_COMMAND_FOUND,		TO_BOTH		},
	{ ALL_STATES,		"REJECT"			,REJECT,				TO_BOTH		},	
	{ HANDSHAKE,		"CLIENT_VERSION"	,CLIENT_VERSION,		TO_SERVER	},
	{ HANDSHAKE,		"SERVER_VERSION"	,SERVER_VERSION,		TO_CLIENT	},	
	{ HANDSHAKE,		"USERNAME"			,USERNAME,				TO_SERVER	},
	{ HANDSHAKE,		"PASSWORD"			,PASSWORD,				TO_SERVER	},
	{ WAIT_FOR_PLAYER,  "GAME_PARAM_WAIT"	,GAME_PARAM_WAIT,		TO_CLIENT	},
	{ WAIT_FOR_PLAYER,  "GAME_PARAM_START"	,GAME_PARAM_START,		TO_CLIENT	},
	{ GAME_NEGOTIATION, "GAME_PARAM"		,GAME_PARAM,			TO_BOTH		}

};

#endif // SHOGICOMMANDMAP_H_INCLUDED

